|
|
|
|
|
|
|
NewTbl.Indexes.Append Idx1
NewTbl.Index = "Zip_Code" |
|
|
|
|
|
|
|
|
If your program needs an index, why not just create it at designtime so you don't have to worry about creating it at runtime? There are several reasons for not doing this: |
|
|
|
|
|
|
|
|
It takes time for the data engine to update indexes after records are added, deleted, or changed. If there are a large number of indexes, this process can be quite time-consuming. It may be better to create the index only when it is needed. Also, indexes take up additional disk resources; so many indexes on a large table can cause your application to exceed available resources. |
|
|
|
|
|
|
|
|
You are limited to 32 indexes for a table. Although this is a fairly large number, if you need more than 32, you must create some indexes as they are needed and then delete them. |
|
|
|
|
|
|
|
|
You may not be able to anticipate all the ways a user of your application wants to view data. By providing a method for creating indexes, specified by the user at runtime, you add flexibility to your application. |
|
|
|
|
|
|
|
|
Of these reasons, the performance issue of updating multiple indexes is the one most often considered. To determine whether it is better to add the index at designtime or to create it only when you need it, set up the application both ways and test the performance of each. |
|
|
|
|
|
|
|
|
|
Although it is desirable to limit the number of indexes your table has to keep current, it is advisable to have an index for each field that is commonly used in SQL queries. This is because the Jet engine (starting with version 2.0) employs query optimization that uses any available indexes to speed up queries.  |
|
|
|
|
|
|
|
|
|
|
Considering Programs That Modify Multiple Records |
|
|
|
|
|
|
|
|
Some programs, or program functions, are meant to find one specific piece of information in a database. However, the vast majority of programs and functions work with multiple records as a group. There are two basic methods of working with multiple records: |
|
|
|
|
| | | |
|
|
|
|
Groups of commands contained inside a Do . . . While, Do . . . Until, or For . . . Next programming structure. The commands are repeated until the exit condition of the loop is met. |
|
|
|
| | |
|
|
|
|
Commands written in Structured Query Language that tell the database engine to process records. SQL is covered in detail in Appendix C, "SQL Summary." |
|
|
|
|
|
|
|
|
|
|
Most programmers are familiar with the use of Do . . . While and For . . . Next loops. When you are working with recordsets, all the programming principles for loops still apply. That is, you can perform a loop while a specific condition exists or for a specific number of records. |
|
|
|
|
|